module.exports = function palyGame(playerAction) {
    if (playerAction !== "rock" && playerAction !== "scissor" && playerAction !== "paper") {
        console.log("请输入 rock 或 scissor 或 paper")
        return
    }

    // 机器随机生成剪刀石头布
    const randomNum = Math.random() * 3
    let computerAction = randomNum < 1 ? "rock" : randomNum < 2 ? "scissor" : "paper"
    console.log(`玩家出：${playerAction}；电脑出：${computerAction}`)

    if (playerAction === computerAction) {
        console.log("平手")
        return 0
    }
    else if (playerAction === "scissor" && computerAction === "paper" || playerAction === "rock" && computerAction === "scissor" || playerAction === "paper" && computerAction === "rock") {
        console.log("你赢了")
        return 1
    } else {
        console.log("你输了")
        return -1
    }
}